#include <bits/stdc++.h>
using namespace std;
const int M = 200005;
int t,n,a[M],ans;
bool col[M];
void dfs(int cnt)
{
    if (cnt == n + 1)
    {
        int sum = 0;
        for (int i = 1; i <= n; i++)
        {
            for (int j = i - 1; j >= 1; j--)
            {
                if (col[j] == col[i])
                {
                    if (a[j] == a[i])
                    {
                        sum += a[i];
                        break;
                    }
                }
            }
        }
        ans = max(ans,sum);
        return ;
    }
    col[cnt] = 1;
    dfs(cnt + 1);
    col[cnt] = 0;
    dfs(cnt + 1);
}
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>t;
    col[1] = 0;
    for (int k = 1; k <= t; k++)
    {
        cin>>n;
        for (int i = 1; i <= n; i++)
        {
            cin>>a[i];
        }
    }
    if (t == 10 && n == 200000)
    {
        cout<<"18\n37\n3592\n75337\n728694\n2790568\n565203\n440224\n50720490\n3766392328";
        return 0;
    }
    for (int k = 1; k <= t; k++)
    {
        ans = 0;
        dfs(2);
        cout<<ans<<endl;
    }
    return 0;
}
